﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DBKit5.UControls
{
    /// <summary>
    /// 连接对象选择器
    /// </summary>
    /// <remarks>2014-3-19 by sutroon</remarks>
    public partial class frmConnectionSelector : Form
    {
        /// <summary>
        /// 获取或设置文本编辑器的内容
        /// </summary>
        public string SQLText { get { return tbSql.Text; } set { tbSql.Text = value; } }
        AppDataHelper adh;
        public frmConnectionSelector()
        {
            InitializeComponent();

            adh = new AppDataHelper();
            btnCancel.Click += new EventHandler(btn_Click);
            btnRun.Click += new EventHandler(btn_Click);
        }
        private void btn_Click(object sender, EventArgs e)
        {
            switch (((Button)sender).Name)
            {
                case "btnRun":
                    if (string.IsNullOrEmpty(SQLText)) return;
                    string msg=adh.RunDistributeScript(ucConnectionSelector1.GetCheckedValues(), SQLText);
                    MessageBox.Show(msg == "SUCCESS" ? "执行成功!" : msg);
                    break;
                case "btnCancel":
                    this.Close();
                    break;
            }
        }
    }
}
